/**
 * Created by WYH on 17/4/17.
 */
angular.module('tribalc').factory('Event', function () {
    
    function addEvent(obj, type, fn){
       if(obj.attachEvent){
           obj.attachEvent('on' + type, fn);
       }
       else{
           obj.addEventListener(type, fn, true);
       }
    }


    function removeEvent(obj, type, fn) {
        if (obj.detachEvent) {
            obj.detachEvent('on' + type, fn);
        } else {
            obj.removeEventListener(type, fn, true);
        }
    }

    return {
        addEvent: addEvent,
        removeEvent: removeEvent
    }
    
});